package com.afkt.project.ui.widget.stickyheaders.viewholder;

import com.afkt.project.ui.widget.stickyheaders.model.ItemModel;
import com.afkt.project.ui.widget.stickyheaders.ultimateprovider.EventTransmissionListener;
import com.afkt.project.ui.widget.stickyheaders.ultimateprovider.UltimateProvider;
import com.afkt.project.ui.widget.stickyheaders.ultimateprovider.ViewHolder;
import com.ohos.afkt.ResourceTable;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.*;
import ohos.agp.components.element.ShapeElement;

public class ItemViewHolder extends ViewHolder<ItemModel> {
    private DirectionalLayout itemLayout;
    private Text tvTitle;
    private Text tvMessage;

    public ItemViewHolder(EventTransmissionListener eventTransmissionListener, Component component, UltimateProvider provider, ComponentContainer componentContainer) {
        super(eventTransmissionListener, component, provider, componentContainer);
        itemLayout = (DirectionalLayout) findComponentById(ResourceTable.Id_itemLayout);
        tvTitle = (Text) findComponentById(ResourceTable.Id_tv_title);
        tvMessage = (Text) findComponentById(ResourceTable.Id_tv_message);
    }

    @Override
    public void onDataBound() {
        tvTitle.setText(getModel().getTitle());
        tvMessage.setText(getModel().getMessage());
        ShapeElement element = new ShapeElement();
        RgbColor rgbColor = new RgbColor(0);
        element.setRgbColor(rgbColor);
        itemLayout.setBackground(element);
    }
}
